﻿Imports Subgurim.Controles
Imports System.Data.OleDb
Partial Public Class _Default
    Inherits System.Web.UI.Page


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
        GMap1.setCenter(New GLatLng(24.69943, 46.72348))
        Dim options As New GMapUIOptions()
        options.maptypes_physical = False
        options.zoom_scrollwheel = True
        GMap1.addGMapUI(New GMapUI())
        GMap1.GZoom = 10

        Dim OleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("RUHRestaurantsDB").ConnectionString)
        Dim location As String = "SELECT RestName,Address FROM Resturants"
        Dim SqlLocation As OleDbCommand = New OleDbCommand(location, OleDbConn)
        OleDbConn.Open()

        Dim dblocation As OleDbDataReader = SqlLocation.ExecuteReader


        If dblocation.HasRows Then

            While dblocation.Read()
                Dim addrs As String = dblocation.Item("Address")
                addrs = (addrs.Replace("(", " ")).Replace(")", " ").Trim()
                Dim address As String() = addrs.Split(",")

                Dim center As New GLatLng(address(0), address(1))
                GMap1.setCenter(center, 9)
                Dim icon As New GMarker(center)
                Dim window As New GInfoWindow(icon, "<br>" & dblocation.Item("RestName") & "</b>", False, GListener.Event.click)
                GMap1.addInfoWindow(window)

            End While

        End If

        dblocation.Close()
        OleDbConn.Dispose()
        OleDbConn.Close()


    End Sub

End Class